package net.csdn.www;

public class Test28 {

	/**
	 * 刘柱栋    2013-3-28
	 * @param args
	 */
	public static void main(String[] args) {
		int[] n = {95,10,58,58,74,98,2,3,14,65,2};
		//selecSort(n);
		int count = 0;
		for(int i = 0 ,size = n.length ; i < size -1 ; i++){
			for(int j = i + 1 ; j < size ; j++){
				if(n[i] > n[j]){
					int temp = n[i];
					n[i] = n[j];
					n[j] = temp;
				}
				count++;
			}
		}
		for(int i : n){
			System.out.print(i + " ");
		}
		System.out.println("===="+count);
	}
	
	private static void selecSort(int[] n){
		int count = 0;
		for(int i = 0 , size = n.length ; i < size - 1 ; i++){
			int temp = i+1;
			while(temp < size ){
				if(n[i] > n[temp]){
					int t = n[i];
					n[i] = n[temp];
					n[temp] = t;
				}
				temp ++;
				count ++;
			}
		}
		for(int i : n){
			System.out.print(i + " ");
		}
		System.out.println("===="+count);
	}

}
